<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="../css/icons-extra.css" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">	
			<a class="mui-icon mui-icon-back mui-action-back mui-pull-left"></a>
			<h1 class="mui-title ">Camera</h1>
			<a class="mui-icon-extra mui-icon-extra-topic mui-pull-right" style="margin-top: 10px;"
				 onclick="openWindow('docCamera','../doc/camera.html?v=20190621')"></a>
		</header>
		<div class="mui-content">
			<div class="mui-content-padded">
				<div class="mui-row">
					Contacts模块管理系统通讯录，用于可对系统通讯录进行增、删、改、查等操作。通过plus.contacts获取系统通讯录管理对象。
				</div>
				<ul id="history" class="dlist" style="text-align:left;">
					<li id="nohistory" class="ditem" onclick="onempty()">无历史记录	</li>
				</ul>
				<br />
				<div class="mui-row" id="divInfo"></div>
			</div>
		</div>
		<script src="../js/mui.min.js"></script>
		<script type="text/javascript" src="../js/app.js" ></script>
		<script type="text/javascript">
			mui.init();
			function outSet(message){
				document.getElementById("divInfo").innerText = message;
			}
			
			function outLine(message){
				var text = document.getElementById("divInfo").innerText;
				document.getElementById("divInfo").innerText = text + "\n" + message;
			}
			mui.plusReady(function(){
				// 扩展API加载完毕，现在可以正常调用扩展API
				plus.contacts.getAddressBook( plus.contacts.ADDRESSBOOK_PHONE, function( addressbook ) {
					// 可通过addressbook进行通讯录操作
					outSet( "Get address book success!" );
					// 向通讯录中添加联系人
//					var contact = addressbook.create();
//					contact.name = {givenName:"王安"};
//					contact.phoneNumbers = [{type:"手机",value:"88888888",preferred:true}];
//					contact.save();
//					outLine("向通讯录中添加联系人成功！");
					addressbook.find([],function(contacts){
						outLine("contacts.length="+contacts.length);
						if(contacts.length <= 0)
							return;
							
						var contact = contacts[0]
						outLine("contact="+JSON.stringify(contact));
						
					}, function () {
						outLine("error");
					},{multiple:true});
					
				}, function ( e ) {
					outSet( "Get address book failed: " + e.message );
				} );
			});
		</script>
	</body>

</html>